﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="User_msg_json.aspx.cs" Inherits="newBlog.CenterInc.view_json.admin.User_msg_json" %>

<%@ Import Namespace="newBlog.CenterInc.model" %>
<%@ Import Namespace="newBlog.CenterInc.Ctrltor" %>
<%@ Import Namespace="System.Web.Script.Serialization" %>

<% 
    Response.ContentType = "application/json";
    if (Session["user_id"]==null) {
        Response.Write("{\"error\":\"您未登录本站\"}");
        return;
    }
    if (Convert.ToInt32(Session["user_grade"])!=1) {
        Response.Write("{\"error\":\"您不是管理员\"}");
        return;
    }
    int page = Request.Form["page"]==null?0:(Convert.ToInt32(Request.Form["page"])-1)*20;
    string grade= Request.Form["grade"] == null||Request.Form["grade"].Length==0? "%%":Request.Form["grade"];
    string user_name=Request.Form["user_name"]==null||Request.Form["user_name"].Length==0?"":Request.Form["user_name"];
    JavaScriptSerializer serializer = new JavaScriptSerializer();
    User_inc user_Inc = new User_inc();
    int count = user_Inc.UserAllMsgCount(user_name,grade);
    List<User_msgDao> list = user_Inc.UserAllMsg(user_name,grade,page);
    string json = "{\"code\":0,\"msg\":\"\",\"count\":"+count+",\"data\":"+serializer.Serialize(list)+"}";

    Response.Write(json);
    %>